<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="content-type" content="text/html; charset=utf-8" />
	<title>${message("编辑机构")}</title>
<link href="/resources/css/common.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="/resources/js/reference/jquery.js"></script>
<script type="text/javascript" src="/resources/js/base/dialog.js"></script>
<script type="text/javascript" src="/resources/js/base/request.js"></script>
<script type="text/javascript" src="/resources/js/base/global.js"></script>
<script type="text/javascript" src="/resources/js/reference/jquery.validate.js"></script>
<script type="text/javascript" src="/resources/js/reference/mmGrid.js"></script>
<link href="/resources/css/mmGrid.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
$().ready(function() {
		
	$inputForm = $("#inputForm");
		
		// 表单验证
	$inputForm.validate({
		rules: {
    		name: "required",
    		sn: "required"	
		} ,
		submitHandler:function(form){
			return false;
		}
	});
	//查询机构
	$("#selectSaleOrg").bindQueryBtn({
		type:'saleOrg',
		title:'${message("查询机构")}',
		url:'/saleOrg/select_saleOrg.jhtml'
	});	
	$("form").bindAttribute({
		isConfirm:true,
	    callback: function(resultMsg){
	        $.message_timer(resultMsg.type,resultMsg.content,1000,function(){
				location.reload(true);
			})
	    }
	 });
});

function del(e){
	var $this = $(e);
		var url="delete.jhtml?id="+$("#sid").val();
		ajaxSubmit($this,{
			 url: url,
			 method: "post",
			 isConfirm:true,
			 confirmText:'您确定要删除吗？',
			 callback:function(resultMsg){
				$.message_timer(resultMsg.type,resultMsg.content,1000,function(){
					parent.change_tab(1,'list.jhtml');
				})
			 }
		})
}
</script>
</head>
<body>
	<div class="pathh">
		&nbsp;${message("查看机构")}
	</div>
	<form id="inputForm" [#if saleOrg.isTop][#else]action="update.jhtml"[/#if] method="post" type="ajax" validate-type="validate">
        <input type="hidden" name="id" id="sid" value="${saleOrg.id}" />
        <input  type="hidden" name="isTop" value="false"/>
        <input  type="hidden" name="isLeaf" value="[#if saleOrg.isLeaf]true[#else]false[/#if]"/>
	<div class="tabContent">
		<table class="input input-edit">
			<tr>
				<th>
					<span class="requiredField"></span>${message("机构类型")}:
				</th>
				<td>
					<select name="type" class="text">
						<option value="0" [#if saleOrg.type == 0]selected="selected"[/#if]>${message("公司") }</option>
						<option value="1" [#if saleOrg.type == 1]selected="selected"[/#if]>${message("客户") }</option>
						<option value="2" [#if saleOrg.type == 2]selected="selected"[/#if]>${message("油库") }</option>
					</select>
				</td>
			[#if saleOrg.parent??]
				<th>${message("上级机构")}:</th>
				<td>
					${saleOrg.parent.name}
					<input type="hidden" name="saleOrgId" value="${saleOrg.parent.id}"/>
				</td>
			[#else]
				<th>${message("上级机构")}:</th>
				<td>${message("顶级机构")}</td>
			[/#if]
				<th>
					<span class="requiredField">*</span>${message("机构名称")}:
				</th>
				<td>
					<input type="text" name="name" class="text" maxlength="200"   btn-fun="clear" value="${saleOrg.name}"/>
				</td>
				<!--
				<th>
					${message("费用预算")}:
				</th>
				<td>
					<span style="color:#f60;">${currency(saleOrg.budget, true)}</span>
				</td>
				-->
				<th>
					<span class="requiredField">*</span>${message("机构编号")}:
				</th>
				<td>
					<input type="text" name="sn" class="text" maxlength="200"   btn-fun="clear" value="${saleOrg.sn}"/>
				</td>
			</tr>
			<tr style="display: none;">
				<th>${message("11091")}</th>
				<td>
					${saleOrg.intf_key}
				</td>
				<th class="noBg"></th><td colspan="3"></td>
			</tr>
			<tr>
				<th>
					${message("11092")}:
				</th>
				<td>
					<label>
						<input type="checkbox" name="isEnabled" value="true" [#if saleOrg.isEnabled == true]checked="checked"[/#if] />是否启用
							<input type="hidden" name="_isEnabled" value="false" />
					</label>
				</td>
				<th class="noBg"></th><td colspan="5"></td>
			</tr>
			<tr>
				<th>
					${message("备注")}:
				</th>
				<td colspan="7">
					<textarea name="memo" class="text">${saleOrg.memo}</textarea>
				</td>
			</tr>
		</table>
		</div>
		<div class="fixed-top">
				<a href="add.jhtml?type=${type}" class="iconButton" id="addButton">
					<span class="addIcon">&nbsp;</span>${message("1001")}
				</a>
			[#if saleOrg.isTop]
			[#else]
				<input type="submit" id="submit_button" class="button sureButton" value="${message("1013")}" />
				<input type="button"  class="button cancleButton" onclick="del(this);" value="${message("删除")}" />
			[/#if]
			<input type="button" onclick="location.reload(true);" class="button refreshButton ml15" value="${message("刷新")}">
		</div>
	</form>
</body>
</html>